<?php
    include_once("Configs/database.php");
    include_once("NguoiDung.php");
    class CanBo extends NguoiDung{
        private $holot;
        private $ten;
        private $ngaysinh;
        private $phai;
        private $diachi;
        private $email;
        private $sodt;
        private $hocvi;
        public function setHoLot($holot){
            $this->holot = $holot;
        }
        public function getHoLot(){
            return $this->holot;
        }
        public function setTen($ten){
            $this->ten = $ten;
        }
        public function getTen(){
            return $this->ten;
        }
        
        public function setNgaySinh($ngaysinh){
            $this->ngaysinh = $ngaysinh;
        }
        public function getNgaySinh(){
            return $this->ngaysinh;
        }
        public function setPhai($phai){
            $this->phai = $phai;
        }
        public function getPhai(){
            return $this->phai;
        }
        
        public function setDiaChi($diachi){
            $this->diachi = $diachi;
        }
        public function getDiaChi(){
            return $this->diachi;
        }
        
        public function setEmail($email){
            $this->email = $email;
        }
        public function getEmail(){
            return $this->email;
        }
        
        public function setSoDT($sodt){
            $this->sodt = $sodt;
        }
        public function getSoDT(){
            return $this->sodt;
        }
        public function setHocVi($hocvi){
            $this->hocvi = $hocvi;
        }
        public function getHocVi(){
            return $this->hocvi;
        }
        public function themCanBo(){
            $query = "insert into CanBo(maso,holot,ten,ngaysinh,phai,diachi,email,sodt,hocvi) values ('".$this->getMaSo()."','".$this->getHoLot()."', ";
            $query .= "'".$this->getTen()."',str_to_date('".$this->getNgaySinh()."','%d-%m-%Y'),".$this->getPhai().",'".$this->getDiaChi()."','".$this->getEmail()."','".$this->getSoDT()."','".$this->getHocVi()."')";
            $this->setQuery($query);
            //echo $this->getQuery();
            return $this->executeQuery();
        }
        public function suaCanBo(){
            $query = "update CanBo set holot='".$this->getHoLot()."',ten='".$this->getTen()."', ";
            $query .= "phai=".$this->getPhai().",diachi='".$this->getDiaChi()."',email='".$this->getEmail()."',sodt='".$this->getSoDT()."',hocvi='".$this->getHocVi()."' where maso='".$this->getMaSo()."'";
             //echo $this->getQuery();
            $this->setQuery($query);
            return $this->executeQuery();
        }
        public function xoaCanBo(){
            $this->setQuery("delete CanBo where  maso='".$this->getMaSo()."'");
            return $this->executeQuery();
        }
        public function thongtinCanBo(){
            $query = "select maso, concat(holot, ' ', ten) as hoten, date_format(ngaysinh, '%d-%m-%Y') as ngaysinh, (case phai when 0 then N'Nữ' when 1 then 'Nam' end) as phai, diachi, email, sodt from CanBo";
            $query .= " where  maso='".$this->getMaSo()."'";
            $this->setQuery($query);
            return $this->fetchAll();
        }
        public function dsCanBo(){
            $this->setQuery("select * from CanBo");
            return $this->fetchAll();
        }
    }
?>